﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace IndividualTask
{
    public partial class logon : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["login"] != null)
            {
                Panel2.Visible = true;
                HyperLink5.Visible = false;
            }
            else
            {
                Panel2.Visible = false;
                HyperLink5.Visible = true;
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            localhost.WebService web = new localhost.WebService();
            if (web.GetUser(TextBox1.Text, TextBox2.Text).Tables[0].Rows.Count == 0)
            {
                Label3.Visible = true;

            }
            else
            {
                 Label3.Visible = false;
                 Session["login"] = TextBox1.Text;
                 Response.Redirect("~/myAccount.aspx");
            }
        }

        protected void Button3_Click(object sender, EventArgs e)
        {
            localhost.WebService web = new localhost.WebService();
            if (web.checkUser(TextBox3.Text).Tables[0].Rows.Count == 0 & TextBox4.Text == TextBox5.Text)
            {
                web.AddUser(TextBox3.Text, TextBox4.Text);
                Session["login"] = TextBox1.Text;
                Response.Redirect("~/myAccount.aspx");
            }
            else 
            {
                Label7.Visible = true;
               

            }


        }

        protected void Button2_Click(object sender, EventArgs e)
        {
            Session.Abandon();
            Response.Redirect(Request.Path);

        }
    }
}